load("//integration:index.bzl", "ng_integration_test")

ng_integration_test(
    name = "run",
    commands = [
        "yarn install --cache-folder ./.yarn_local_cache",
        "yarn ng build",
        "node ./dist/ssr-benchmarks/server/server.mjs",
    ],
    tags = ["manual"],
)

## This target is intended to run the benchmark in a browser
## For this the benchmark script is loaded by an html page serve the http-server script
## Note: This target doesn't end until the http-server is stopped. It should not run as part of our testset.
ng_integration_test(
    name = "run_browser",
    commands = [
        "yarn install --cache-folder ./.yarn_local_cache",

        #
        "NG_BUILD_MANGLE=0 yarn ng build --configuration production,browser",
        "yarn http-server ./dist",
    ],
    tags = ["manual"],
)

# This target is mostly intended for investigating via the devTools using the flamechart
ng_integration_test(
    name = "run_browser_emulated_dom",
    commands = [
        "yarn install --cache-folder ./.yarn_local_cache",

        # We keep the symbols with the NG_BUILD_MANGLE flag
        "NG_BUILD_MANGLE=0 yarn ng build",
        "yarn http-server ./dist",
    ],
    tags = ["manual"],
)

# This is a target to investigate with deopt explorer (https://github.com/microsoft/deoptexplorer-vscode)
# The v8 log file will be generated in the test directory
ng_integration_test(
    name = "run_deopt",
    commands = [
        "yarn install --cache-folder ./.yarn_local_cache",
        "NG_BUILD_MANGLE=0 yarn ng build",
        "yarn node  --prof \
            --log-deopt \
            --log-ic \
            --log-maps \
            --log-maps-details \
            --log-internal-timer-events \
            --log-code \
            --log-source-code \
            --detailed-line-info \
            ./dist/ssr-benchmarks/server/server.mjs narrowRun",
    ],
    tags = ["manual"],
)
